#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>

int removeElement(int* nums, int numsSize, int val)
{
    int begin = 0;
    while (begin < numsSize)
    {
        if (nums[begin] == val)
        {
            for (int i = begin; i < numsSize; i++)
            {
                nums[i] = nums[i + 1];
            }
        }
        else if (nums[begin] != val)
            begin++;
    }
    return begin;
}

int main()
{
    int num[] = { 0,1,2,2,3,0,4,2 };
    int sz = 8;
    int val = 2;
    int ret=removeElement(num, sz, val);
    printf("%d", ret);
    return 0;
}

